package com.own.component.mybatis.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * SqlMethod
 *
 * @author chenxueli
 * @date 2020/9/22 9:14
 */
@Getter
@AllArgsConstructor
public enum SqlMethod {
    /**
     * 批量插入（全字段）
     */
    INSERT_BATCH("insertBatch", "批量插入（全字段）", "<script> insert into %s %s value %s</script>"),
    /**
     * 忽略插入（全字段）
     */
    INSERT_IGNORE("insertIgnore", "存在则不插入", "<script>\ninsert ignore into %s %s values %s\n</script>"),
    /**
     * 替换插入（全字段）
     */
    REPLACE("replace", "替换插入", "<script>\nreplace into %s %s values %s\n</script>"),
    /**
     * 批量修改（全字段）
     */
    UPDATE_ID_BATCH("updateByIdBatch", "批量修改（全字段）", "<script> update %s %s where %s </script>"),
    /**
     * 查询最大的序号
     */
    MAX_SORT_ORDER("maxSortOrder", "查询最大的序号", "<script>%s select ifnull(max(sort_order), -1) from %s %s</script>"),
    /**
     * 查询最小的序号
     */
    MIN_SORT_ORDER("minSortOrder", "查询最小的序号", "<script>%s select ifnull(min(sort_order), -1) from %s %s</script>"),
    /**
     * 递减序号
     */
    UPDATE_DECREASE_ORDER("updateDecreaseOrder", "递减序号", "<script> update %s %s %s %s </script>"),
    /**
     * 递增序号
     */
    UPDATE_INCREASE_ORDER("updateIncreaseOrder", "递增序号", "<script> update %s %s %s %s </script>"),
    /**
     * todo 根据任意字段查询
     */
    GET_BY_FIELD("getByField", "根据任意字段查询", "<script>select %s form %s %s</script>"),
    /**
     * todo 根据任意字段查询
     */
    LIST_BY_FIELD("listByField", "根据任意字段查询", "<script>select %s form %s %s</script>");

    private final String method;
    private final String desc;
    private final String sql;

}
